package com.leo.contentcenter.feignclient;

import com.leo.contentcenter.domain.dto.user.UserDTO;
import com.leo.contentcenter.feignclient.fallback.UserCenterFeignClientFallback;
import com.leo.contentcenter.feignclient.fallbackfactory.UserCenterFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @author leo
 */
//@FeignClient(name = "user-center", configuration = UserCenterFeignConfiguration.class)
@FeignClient(name = "user-center",
//        fallback = UserCenterFeignClientFallback.class,
        //注意使用了 fallbackFactory 不能使用fallback，fallbackFactory能拿到异常，fallback不行
        fallbackFactory = UserCenterFeignClientFallbackFactory.class)
public interface UserCenterFeignClient {

    //@FeignClient(name = "user-center") 表明这个接口是feignClient name指定要请求的微服务名称

    /**
     * 请求http://user-center/users/{id} 根据id查找用户信息
     * @param id 用户id
     * @return 返回用户信息
     */
    @GetMapping("users/{id}")
    UserDTO findById(@PathVariable Integer id);

}
